import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {

  // 接收父组件传来的数据
  @Input() title;
  @Input() msg;
  @Input() run;
  @Input() home;
  constructor() { }

  ngOnInit(): void {
  }

  getParentMsg() {
    // 获取父组件的数据
    alert(this.msg);
  }

  getParentRun() {
    // 执行父组件的run方法
    // this.run();

    alert(this.home.msg);

    this.home.run();
  }
}
